﻿using SharpDX.DirectWrite;

namespace Ensemble_Windows
{
    /// <summary>
    /// 文字帮助类
    /// </summary>
    public sealed class TextHelper
    {
        /// <summary>
        /// 获取Format
        /// </summary>
        /// <param name="FactoryDWrite">一般在Initialize传值</param>
        /// <returns></returns>
        public static TextFormat GetFormat(Factory FactoryDWrite)
        {
            TextFormat textFormat = new TextFormat(FactoryDWrite, "宋体", 12)
            {
                TextAlignment = TextAlignment.Center,
                ParagraphAlignment = ParagraphAlignment.Center
            };
            return textFormat;
        }

        /// <summary>
        /// 获取Layout
        /// </summary>
        /// <param name="FactoryDWrite"><see cref="Factory"/></param>
        /// <param name="text">文字</param>
        /// <param name="configuration">配置</param>
        /// <param name="format"><see cref="TextFormat"/></param>
        /// <returns></returns>
        public static TextLayout GetLayout(Factory FactoryDWrite, string text, Configuration configuration, TextFormat format)
        {
            TextLayout textLayout = new TextLayout(FactoryDWrite, text, format, configuration.Width, configuration.Height);
            return textLayout;
        }
    }
}
